<!--  -->
<template>
<div class='innexForm'>
  <el-form :model="formData" ref="formData" :disabled="true" label-width="120px"
            size="mini">
    <el-row :gutter="10">
      <el-col :span="12">
        <el-form-item label="案(事)件名称：" prop="caseName" >
          <el-input v-model="formData.caseName" placeholder="暂无内容" autocomplete="off"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="发生日期：" >
          <div class="block">
            <el-date-picker
              v-model="formData.happenDate"
              type="date"
              value-format="timestamp"
              format="yyyy 年 MM 月 dd 日"
              placeholder="暂无内容"
              :picker-options="dataPickerBeforeTodayOptions">
            </el-date-picker>
          </div>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="发生地：" prop="happenAddress" >
          <el-input v-model="formData.happenAddress" autocomplete="off" placeholder="暂无内容"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="发生地详址：" prop="happenFullAddress" >
          <el-input v-model="formData.happenFullAddress" autocomplete="off" placeholder="暂无内容"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="案(事)件分级：" prop="caseLevel" >
          <el-select v-model="formData.caseLevel" placeholder="暂无内容">
            <el-option v-for="(item,index) in caseLevelOption" :key="index" :label="item.name" :value="item.code"></el-option>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="12">
        <el-form-item label="案(事)件类型：" prop="caseType" >
          <el-select v-model="formData.caseType" placeholder="暂无内容">
            <el-option v-for="(item,index) in caseTypeOption" :key="index" :label="item.name" :value="item.code"></el-option>
          </el-select>
        </el-form-item>
      </el-col>
      <el-col :span="24">
        <el-form-item label="案(事)件情况："  class="custom-textarea-container">
          <el-input type="textarea" v-model="formData.caseSituation" placeholder="暂无内容"></el-input>
        </el-form-item>
      </el-col>
      <el-col :span="24">
        <el-form-item label="街道/社区/网格：" prop="gridIdArr" >
          <div class="block">
            <el-cascader
              placeholder="暂无内容"
              :options="treeData"
              style="width:100%"
              filterable
              clearable
              :props="gridIdProps"
              v-model="formData.gridIdArr">
            </el-cascader>
          </div>
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</div>
</template>

<script>
// 这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
// 例如：import 《组件名称》 from '《组件路径》';
import { getUserGridTree } from '@/utils/SessionDataUtil'
import { getAllRegion } from '@/utils/region'
import {getDictDataOption} from '@/utils/getDictDataOption'
import {getImptntCasDetail} from '@/http/PublicSecurityAppApi'
export default {
// import引入的组件需要注入到对象中才能使用
  name: 'BigCaseForm',
  props: {
    detailForm: {
      type: Object,
      default: function () {
        return {
        }
      }
    }
  },
  components: {},
  data () {
    // 这里存放数据
    return {
      formData: {},
      queryData: {},
      treeData: [],
      treeOption: [],
      caseLevelOption: [],
      caseTypeOption: [],
      gridIdProps: {
        label: 'name',
        value: 'id'
      },
      dataPickerBeforeTodayOptions: {
        disabledDate (time) {
          return time.getTime() > Date.now()
        }
      }
    }
  },
  // 方法集合
  methods: {
    getTreeData () {
      let gridTree = getUserGridTree()
      if (gridTree && gridTree instanceof Array) {
        this.treeData = gridTree
        this.treeOption = gridTree
      }
    },
    getDetail (data) {
      getImptntCasDetail(data).then(resp => {
        if (resp.code && resp.code === '200') {
          let data = resp.data
          if (data) {
            this.formData = data
            let regionData = {}
            regionData.id = this.formData.gridId
            regionData.items = this.treeData
            let gridIdArr = getAllRegion(regionData)
            this.$set(this.formData, 'gridIdArr', gridIdArr)
          }
        }
      })
    }
  },
  // 监听属性 类似于data概念
  computed: {},
  // 监控data中的数据变化
  watch: {
    detailForm: {
      handler: function (data) {
        this.getDetail(data)
      },
      deep: true,
      immediate: true
    }
  },
  // 生命周期 - 创建完成（可以访问当前this实例）
  created () {

  },
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted () {
    this.getTreeData()
    this.caseLevelOption = getDictDataOption('案（事）件分级')
    this.caseTypeOption = getDictDataOption('案（事）件类型')
  },
  beforeCreate () {}, // 生命周期 - 创建之前
  beforeMount () {}, // 生命周期 - 挂载之前
  beforeUpdate () {}, // 生命周期 - 更新之前
  updated () {}, // 生命周期 - 更新之后
  beforeDestroy () {}, // 生命周期 - 销毁之前
  destroyed () {}, // 生命周期 - 销毁完成
  activated () {} // 如果页面有keep-alive缓存功能，这个函数会触发
}
</script>
